import {defHttp} from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";

const { createConfirm } = useMessage();

enum Api {
  list = '/nurse_user/nurseUser/list',
  save='/nurse_user/nurseUser/add',
  edit='/nurse_user/nurseUser/edit',
  deleteOne = '/nurse_user/nurseUser/delete',
  deleteBatch = '/nurse_user/nurseUser/deleteBatch',
  clearUserInfo = '/nurse_user/nurseUser/clearUserInfo',
  importExcel = '/nurse_user/nurseUser/importExcel',
  exportXls = '/nurse_user/nurseUser/exportXls',
  nurseUserFamilyList = '/nurse_user/nurseUser/listNurseUserFamilyByMainId',
  nurseUserFamilySave='/nurse_user/nurseUser/addNurseUserFamily',
  nurseUserFamilyEdit='/nurse_user/nurseUser/editNurseUserFamily',
  nurseUserFamilyDelete = '/nurse_user/nurseUser/deleteNurseUserFamily',
  nurseUserFamilyDeleteBatch = '/nurse_user/nurseUser/deleteBatchNurseUserFamily',
  nurseUserAddrList = '/nurse_user/nurseUser/listNurseUserAddrByMainId',
  nurseUserAddrSave='/nurse_user/nurseUser/addNurseUserAddr',
  nurseUserAddrEdit='/nurse_user/nurseUser/editNurseUserAddr',
  nurseUserAddrDelete = '/nurse_user/nurseUser/deleteNurseUserAddr',
  nurseUserAddrDeleteBatch = '/nurse_user/nurseUser/deleteBatchNurseUserAddr',
  nurseUserIntegralList = '/nurse_user/nurseUser/listNurseUserIntegralByMainId',
  nurseUserIntegralSave='/nurse_user/nurseUser/addNurseUserIntegral',
  nurseUserIntegralEdit='/nurse_user/nurseUser/editNurseUserIntegral',
  nurseUserIntegralDelete = '/nurse_user/nurseUser/deleteNurseUserIntegral',
  nurseUserIntegralDeleteBatch = '/nurse_user/nurseUser/deleteBatchNurseUserIntegral',
  nurseUserSpecialList = '/nurse_user/nurseUser/listNurseUserSpecialByMainId',
  nurseUserSpecialSave='/nurse_user/nurseUser/addNurseUserSpecial',
  nurseUserSpecialEdit='/nurse_user/nurseUser/editNurseUserSpecial',
  nurseUserSpecialDelete = '/nurse_user/nurseUser/deleteNurseUserSpecial',
  nurseUserSpecialDeleteBatch = '/nurse_user/nurseUser/deleteBatchNurseUserSpecial',
}
/**
 * 导出api
 * @param params
 */
export const getExportUrl = Api.exportXls;

/**
 * 导入api
 */
export const getImportUrl = Api.importExcel;
/**
 * 列表接口
 * @param params
 */
export const list = (params) =>
  defHttp.get({url: Api.list, params});

/**
 * 删除单个
 */
export const deleteOne = (params,handleSuccess) => {
  return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}
/**
 * 批量删除
 * @param params
 */
export const batchDelete = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}
/**
 * 保存或者更新
 * @param params
 */
export const saveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.edit : Api.save;
  return defHttp.post({url: url, params});
}
/**
 * 列表接口
 * @param params
 */
export const nurseUserFamilyList = (params) => {
  if(params['id']){
    return defHttp.get({url: Api.nurseUserFamilyList, params});
  }
  return Promise.resolve({});
}


/**
 * 删除单个
 */
export const nurseUserFamilyDelete = (params,handleSuccess) => {
  return defHttp.delete({url: Api.nurseUserFamilyDelete, params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}
/**
 * 批量删除
 * @param params
 */
export const nurseUserFamilyDeleteBatch = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.nurseUserFamilyDeleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}
/**
 * 保存或者更新
 * @param params
 */
export const  nurseUserFamilySaveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.nurseUserFamilyEdit : Api.nurseUserFamilySave;
  return defHttp.post({url: url, params});
}
/**
 * 导入
 */
export const nurseUserFamilyImportUrl = '/nurse_user/nurseUser/importNurseUserFamily'

/**
 * 导出
 */
export const nurseUserFamilyExportXlsUrl = '/nurse_user/nurseUser/exportNurseUserFamily'
/**
 * 列表接口
 * @param params
 */
export const nurseUserAddrList = (params) => {
  if(params['userId']){
    return defHttp.get({url: Api.nurseUserAddrList, params});
  }
  return Promise.resolve({});
}


/**
 * 删除单个
 */
export const nurseUserAddrDelete = (params,handleSuccess) => {
  return defHttp.delete({url: Api.nurseUserAddrDelete, params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}
/**
 * 批量删除
 * @param params
 */
export const nurseUserAddrDeleteBatch = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.nurseUserAddrDeleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}
/**
 * 保存或者更新
 * @param params
 */
export const  nurseUserAddrSaveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.nurseUserAddrEdit : Api.nurseUserAddrSave;
  return defHttp.post({url: url, params});
}
/**
 * 导入
 */
export const nurseUserAddrImportUrl = '/nurse_user/nurseUser/importNurseUserAddr'

/**
 * 导出
 */
export const nurseUserAddrExportXlsUrl = '/nurse_user/nurseUser/exportNurseUserAddr'
/**
 * 列表接口
 * @param params
 */
export const nurseUserIntegralList = (params) => {
  if(params['userId']){
    return defHttp.get({url: Api.nurseUserIntegralList, params});
  }
  return Promise.resolve({});
}


/**
 * 删除单个
 */
export const nurseUserIntegralDelete = (params,handleSuccess) => {
  return defHttp.delete({url: Api.nurseUserIntegralDelete, params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}
/**
 * 批量删除
 * @param params
 */
export const nurseUserIntegralDeleteBatch = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.nurseUserIntegralDeleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}
/**
 * 保存或者更新
 * @param params
 */
export const  nurseUserIntegralSaveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.nurseUserIntegralEdit : Api.nurseUserIntegralSave;
  return defHttp.post({url: url, params});
}
/**
 * 导入
 */
export const nurseUserIntegralImportUrl = '/nurse_user/nurseUser/importNurseUserIntegral'

/**
 * 导出
 */
export const nurseUserIntegralExportXlsUrl = '/nurse_user/nurseUser/exportNurseUserIntegral'
/**
 * 列表接口
 * @param params
 */
export const nurseUserSpecialList = (params) => {
  if(params['userId']){
    return defHttp.get({url: Api.nurseUserSpecialList, params});
  }
  return Promise.resolve({});
}


/**
 * 删除单个
 */
export const nurseUserSpecialDelete = (params,handleSuccess) => {
  return defHttp.delete({url: Api.nurseUserSpecialDelete, params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}
/**
 * 批量删除
 * @param params
 */
export const nurseUserSpecialDeleteBatch = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.nurseUserSpecialDeleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}
/**
 * 保存或者更新
 * @param params
 */
export const  nurseUserSpecialSaveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.nurseUserSpecialEdit : Api.nurseUserSpecialSave;
  return defHttp.post({url: url, params});
}
/**
 * 导入
 */
export const nurseUserSpecialImportUrl = '/nurse_user/nurseUser/importNurseUserSpecial'

/**
 * 导出
 */
export const nurseUserSpecialExportXlsUrl = '/nurse_user/nurseUser/exportNurseUserSpecial'

/**
 * 清除用户数据
 * @param params
 */
export const clearUserInfo = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认清除用户数据',
    content: '此操作将清除该用户及其关联的所有数据，包括客户端用户信息、监护人、订单信息、医护端注册信息等，是否确认清除？',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.clearUserInfo, params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}
